<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
	require_once("database.php");
	require_once("facebook_include.php");
  	login();
  	 $friends = count(getFriends());
    $wallCount = getUserWallCount();
    $userId = getUserId();
    $name = getUserName();
    if (isset($_GET['state'])){
		//echo "Going to create users";
		$id = $_GET['id'];
		$addr1 = str_replace(',' , ' ', $_GET['addr1']);
		$addr2 = str_replace(',' , ' ', $_GET['addr2']);
		$city = $_GET['city'];
		$state = $_GET['state'];
        $country = $_GET['country'];
		$zip = $_GET['zip'];
		$email = $_GET['email'];
		$payment = $_GET['payment'];
		$paypalid = $_GET['paypalId'];
		createUser($id, $addr1, $addr2, $city, $state, $zip, $country, $email, $friends, $wallCount, $payment, $paypalid, $name);
  		$friendsAdded = addFriends();  		
  	}
?>
<!--block_head-->
<link href="App_Themes/Intel.com/grids-min.css" rel="stylesheet" type="text/css" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<link href="App_Themes/Intel.com/v3.css" rel="stylesheet" type="text/css" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<!--object-specific stylesheets-->
<link href="App_Themes/Intel.com/downloads.css" rel="stylesheet" type="text/css">
<!--/object-specific stylesheets-->
<!--/block_head-->

<!-- Facebook -->
<link rel="stylesheet" href="http://static.ak.facebook.com/css/fb_connect.css" type="text/css" />
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
    function fb_inviteFriends() {
    	FB.Connect.requireSession( 
                function() { 
                    var uid = FB.Facebook.apiClient.get_session().uid;
                    var fbml = fb_getInviteFBML();
                    var dialog = new FB.UI.FBMLPopupDialog("Investment Game", fbml) ;
                    dialog.setContentWidth(650);
                    dialog.setContentHeight(550);
                    dialog.show();
                }
            );
    } 

    function fb_getInviteFBML() {
        var uid = FB.Facebook.apiClient.get_session().uid;
        var fbml = '';
        fbml = 
        '<fb:fbml>\n' +
            '<fb:request-form\n'+
                                //Redirect back to this page
                                ' action="http://ec2-50-16-95-225.compute-1.amazonaws.com/trustgame/registered.php"\n'+
                                ' method="GET"\n'+
                                ' invite="true"\n'+
                                ' type="Investment Game Invite"\n' +
                                ' content="Sign up for a chance to play the Investment Game and get rewarded with real money. This is a field study conducted by researchers from University of Minnesota and University of Connecticut conducting a field experiment on social networking and trust.<fb:req-choice url=\'http://apps.facebook.com/trustgame\' label=\'Accept\'"\n'+ 
                          '>\n'+
                           ' <fb:multi-friend-selector\n'+
                                ' rows="2"\n'+
                                ' cols="4"\n'+
                                ' showborder="false"\n'+
		            				  ' email_invite="true"\n'+
                                ' import_external_friends="false"\n'+
                                ' actiontext="Use this form to invite your friends to Investment Game."/>\n'+
                    ' </fb:request-form>'+
            ' </fb:fbml>';
        return fbml;
    }
</script>
<!-- /Facebook -->

</head>

<?php

	if(isset($_GET['ids'])){
        $ids = $_GET['ids'];
        $count = count($ids);
        updateInviteCount($userId, $count);
    }

?>

<body>
<div id="doc" style="width:700px; padding-left:0px; margin-left:0px"> 
	   <div id="bd">
	   		<div id="yui-main"> 
				<div class="yui-b">
					<div class="yui-g">
						<div class="pageHeading" style="padding:15px 10px 15px 0px;">Investment Game!!</div>
                        <br/>
                        <div class="sectionHeading">Registration Done </div>
						<div style="padding:0px 0px 15px 0px;">
							<p class="font4">Thanks for signing up. We will be contacting you within a week via email if you are chosen to play the game. Please look for a mail from the "Investment Game Administrator." </p>
						</div>
						<div class="sectionHeading">Invite Friends</div>
						<div style="padding:0px 0px 15px 0px;">
							<p class="font4">You can invite your friends in two ways. <a href="javascript:fb_inviteFriends();">Click here</a> to invite them through Facebook or you can copy/paste the following text into an email and send it to your friends</p>
							<!--div class="font4"><strong><a href="javascript:fb_inviteFriends();">Add New Friends</a></strong></div-->
							<p class="font4">Sign up for a chance to play the Investment Game and get rewarded with real money. This is an approved field study conducted by researchers from University of Minnesota and University of Connecticut. If you want to play click on http://apps.facebook.com/trustgame</p>
							<p class="font4">If you have any questions feel free to contact the researchers at <a href="mailto:srice@business.uconn.edu">srice@business.uconn.edu</a> or <a href="rbapna@umn.edu">rbapna@umn.edu</a>.</p>
						</div>
					</div>
				</div>
	   		</div> 
	   </div> 
	   <div id="test">
	   </div> 
</div>
</body>
<?php
	if (isset($_GET['state'])){
		//echo "Going to create users";
		$id = $_GET['id'];
		userStream($id);
  		//getPhotos($id);
  	}
 ?>
<script type="text/javascript">
    FB_RequireFeatures(["Connect"], function(){ FB.Facebook.init("7a940f3dedc63836058c0f8d8666bbbc", "xd_receiver.htm");});
</script>
</html>
